home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
dev
/
c
/
vbcc.lha
/
vbcc
/
alias.c
next >
Wrap
C/C++ Source or Header
|
1997-12-30
|
12KB
|
311 lines
/* $VER: vbcc (alias.c) V0.4 */
/* Listen benutzter/veraenderter Variablen und Behandlung von Decknamen. */
#include "opt.h"
static char FILE_[]=__FILE__;
int p_typ(struct Var *v)
/* Liefert den Typ, auf den Variable zeigen kann. Falls nicht eindeutig */
/* wird CHAR zurueckgegeben, da ein char * auf alles zeigen kann. */
{
struct Typ *t=v->vtyp;int f;
/* Kein Zeiger? Dann moeglicherweise Struktur, die verschiedene Zeiger */
/* enthalten koennte. Koennte man evtl. noch genauer pruefen. */
if((t->flags&NQ)!=POINTER||!t->next||(v->flags&DNOTTYPESAFE)) return(CHAR);
f=t->next->flags&NQ;
if(f==VOID) f=CHAR;
return(f);
}
void ic_changes(struct IC *p,unsigned char *result)
/* Initialisiert den Bitvektor result mit allen Variablen, die durch das */
/* IC p geaendert werden koennten. */
{
int i,j,t,t2;struct Var *v;
memset(result,0,vsize);
t=p->typf&NQ;
if(p->z.flags&VAR){
v=p->z.v;
i=v->index;
/* Hilfsvariable, die waehrend diesem cse-Durchlauf eingefuehrt */
/* wurde. */
if(i<0) return;
if(p->z.flags&DREFOBJ) i+=vcount-rcount;
if(i>=vcount) ierror(0);
BSET(result,i);
/* Wenn p geaendert wird, wird auch *p geaendert */
if(i<rcount) BSET(result,i+vcount-rcount);
if(p->z.flags&DREFOBJ){
if(noaliasopt){
bvunite(result,av_drefs,vsize);
bvunite(result,av_address,vsize);
bvunite(result,av_globals,vsize);
}else{
for(j=0;j<vcount-rcount;j++){
v=vilist[j];
if(!v) ierror(0);
if(v->nesting==0||v->storage_class==EXTERN||(v->flags&USEDASADR)){
struct Typ *tp=v->vtyp;
if(!v->vtyp) ierror(0);
do{
t2=tp->flags&NQ;
tp=tp->next;
}while(t2==ARRAY);
if(t==t2||t==CHAR||t2>POINTER){
BSET(result,j);
if(j<rcount) BSET(result,j+vcount-rcount);
continue;
}
}
if(j<rcount){
t2=p_typ(v);
if(t==t2||t==CHAR||t2==CHAR||t2>POINTER) BSET(result,j+vcount-rcount);
}
}
}
}else{
if(v->nesting==0||v->storage_class==EXTERN||(v->flags&USEDASADR)){
if(noaliasopt){
bvunite(result,av_drefs,vsize);
}else{
for(j=0;j<rcount;j++){
t2=p_typ(vilist[j]);
if(t==t2||t2==CHAR||t>POINTER) BSET(result,j+vcount-rcount);
}
}
}
}
}
if(p->code==CALL){
bvunite(result,av_drefs,vsize);
bvunite(result,av_address,vsize);
bvunite(result,av_globals,vsize);
bvunite(result,av_statics,vsize);
}
}
void ic_uses(struct IC *p,unsigned char *result)
/* Initialisiert den Bitvektor result mit allen Variablen, die durch das */
/* IC p benutzt werden koennten. */
{
int i,j,t,t2,c;struct Var *v;struct Typ *tp;
memset(result,0,vsize);
c=p->code;t=p->typf&NQ;
if(c!=ADDRESS){
if((p->q1.flags&(VAR|VARADR))==VAR){
v=p->q1.v;
i=v->index;
if(c==ADDI2P||c==SUBIFP||c==SUBPFP) t=POINTER;
if(c==CONVCHAR||c==CONVUCHAR) t=CHAR;
if(c==CONVSHORT||c==CONVUSHORT) t=SHORT;
if(c==CONVINT||c==CONVUINT) t=INT;
if(c==CONVLONG||c==CONVULONG) t=LONG;
if(c==CONVFLOAT) t=FLOAT;
if(c==CONVDOUBLE) t=DOUBLE;
if(c==CONVPOINTER) t=POINTER;
if(i>=vcount) {pric2(stdout,p);ierror(0);}
BSET(result,i);
if(v->nesting==0||v->storage_class==EXTERN||(v->flags&USEDASADR)){
if(noaliasopt){
bvunite(result,av_drefs,vsize);
}else{
for(j=0;j<rcount;j++){
t2=p_typ(vilist[j]);
if(t==t2||t2==CHAR||t>POINTER) BSET(result,j+vcount-rcount);
}
}
}
if(p->q1.flags&DREFOBJ){
BSET(result,i+vcount-rcount);
if(noaliasopt){
bvunite(result,av_drefs,vsize);
bvunite(result,av_address,vsize);
bvunite(result,av_globals,vsize);
}else{
for(j=0;j<vcount-rcount;j++){
v=vilist[j];
if(v->nesting==0||v->storage_class==EXTERN||(v->flags&USEDASADR)){
tp=v->vtyp;
do{
t2=tp->flags&NQ;
tp=tp->next;
}while(t2==ARRAY);
if(t==t2||t==CHAR||t2>POINTER||t>POINTER) BSET(result,j);
}
if(j<rcount){
t2=p_typ(v);
if(t==t2||t==CHAR||t2==CHAR||t>POINTER) BSET(result,j+vcount-rcount);
}
}
}
}
}
if((p->q2.flags&(VAR|VARADR))==VAR){
v=p->q2.v;
i=v->index;
if(c==SUBPFP) t=POINTER;
if(i>=vcount) {pric2(stdout,p);ierror(0);}
BSET(result,i);
if(v->nesting==0||(v->flags&USEDASADR)){
if(noaliasopt){
bvunite(result,av_drefs,vsize);
}else{
for(j=0;j<rcount;j++){
t2=p_typ(vilist[j]);
if(t==t2||t2==CHAR||t>POINTER) BSET(result,j+vcount-rcount);
}
}
}
if(p->q2.flags&DREFOBJ){
BSET(result,i+vcount-rcount);
if(noaliasopt){
bvunite(result,av_drefs,vsize);
bvunite(result,av_address,vsize);
bvunite(result,av_globals,vsize);
}else{
for(j=0;j<vcount-rcount;j++){
v=vilist[j];
if(v->nesting==0||v->storage_class==EXTERN||(v->flags&USEDASADR)){
tp=v->vtyp;
do{
t2=tp->flags&NQ;
tp=tp->next;
}while(t2==ARRAY);
if(t==t2||t==CHAR||t2>POINTER) BSET(result,j);
}
if(j<rcount){
t2=p_typ(v);
if(t==t2||t==CHAR||t2==CHAR) BSET(result,j+vcount-rcount);
}
}
}
}
}
}
if((p->z.flags&(VAR|VARADR|DREFOBJ))==(VAR|DREFOBJ)){
v=p->z.v;
i=v->index;
if(i>=vcount) {pric2(stdout,p);ierror(0);}
BSET(result,i);
if(c==ADDI2P||c==SUBIFP) t=POINTER;
if(v->nesting==0||v->storage_class==EXTERN||(v->flags&USEDASADR)){
if(noaliasopt){
bvunite(result,av_drefs,vsize);
}else{
for(j=0;j<rcount;j++){
t2=p_typ(vilist[j]);
if(t==t2||t2==CHAR||t>POINTER||t2>POINTER) BSET(result,j+vcount-rcount);
}
}
}
}
if(p->code==CALL){
bvunite(result,av_drefs,vsize);
bvunite(result,av_address,vsize);
bvunite(result,av_globals,vsize);
bvunite(result,av_statics,vsize);
}
}
void free_alias(struct flowgraph *fg)
/* Gibt alle use/change-Listen der ICs im Flussgraphen frei. */
{
st